package com.csp.mingyue.minio.controller;

import cn.hutool.core.util.RandomUtil;
import com.csp.mingyue.minio.service.AliyunSmsService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 短信推送接口
 *
 * @author Strive
 * @date 2023/4/16 10:48
 */
@RestController
@RequestMapping("/sms")
@RequiredArgsConstructor
public class SmsController {

  private final AliyunSmsService smsService;

  @GetMapping("/send")
  public ResponseEntity<Boolean> send(String phone) throws Exception {
    return ResponseEntity.ok(smsService.sendCode(phone, RandomUtil.randomNumbers(4)));
  }
}
